home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_ghostscript.idb / usr / freeware / doc / ghostscript / 3.33 / language.doc.z / language.doc
Encoding:
Text File  |  1998-05-21  |  17.0 KB  |  461 lines

  1.    Copyright (C) 1989, 1995 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of GNU Ghostscript.
  4.   
  5.   GNU Ghostscript is distributed in the hope that it will be useful, but
  6.   WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility to
  7.   anyone for the consequences of using it or for whether it serves any
  8.   particular purpose or works at all, unless he says so in writing.  Refer
  9.   to the GNU Ghostscript General Public License for full details.
  10.   
  11.  
  12. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  13.  
  14. This file, language.doc, describes the relationship between the
  15. Ghostscript interpreter and the PostScript language.  This file describes
  16. version 3.33 of Ghostscript.
  17.  
  18. For an overview of Ghostscript and a list of the documentation files, see
  19. README.
  20.  
  21. The Ghostscript interpreter, except as noted below, is intended to execute
  22. properly any source program written in the (Level 2) PostScript language as
  23. defined in the December 1990 printing of the PostScript Language Reference
  24. Manual (Second Edition) published by Addison-Wesley (ISBN 0-201-18127-4).
  25. However, the interpreter is configurable in ways that can restrict it to
  26. various subsets of this language.  Specifically, the base interpreter
  27. accepts the Level 1 subset of the PostScript language, as defined in the
  28. first edition of the PostScript Language Reference Manual, ISBN
  29. 0-201-10174-2, Addison-Wesley, 1985, plus the file system, version 25.0
  30. language, and miscellaneous additions listed in sections A.1.6, A.1.7, and
  31. A.1.8 of the Second Edition respectively, including allowing a string
  32. operand for the 'status' operator.  The base interpreter may be configured
  33. by adding any combination of the following:
  34.  
  35.     - The ability to process PostScript Type 1 fonts.  This facility is
  36. normally included in the interpreter.
  37.  
  38.     - The CMYK color extensions listed in section A.1.4 of the Second
  39. Edition (including colorimage).  These facilities are only available if the
  40. color, dps, or level2 feature was selected at the time that Ghostscript was
  41. compiled and linked.
  42.  
  43.     - The Display PostScript extensions listed in section A.1.3
  44. of the Second Edition, but excluding the operators listed in section
  45. A.1.2.  These facilities are only available if the dps feature or the
  46. level2 feature was selected at the time that Ghostscript was compiled
  47. and linked.
  48.  
  49.     - The composite font extensions listed in section A.1.5 of the
  50. Second Edition, and the ability to handle Type 0 fonts.  These facilities
  51. are only available if the compfont feature or the level2 feature was
  52. selected at the time that Ghostscript was compiled and linked.
  53.  
  54.     - The PostScript Level 2 "filter" facilities aside from DCTEncode
  55. and DCTDecode filters.  These facilities are only available if the filter,
  56. dps, or level2 feature was selected at the time that Ghostscript was
  57. compiled and linked.
  58.  
  59.     - The PostScript Level 2 DCTEncode and DCTDecode filters.  These
  60. facilities are only available if the dct or level2 feature was selected at
  61. the time that Ghostscript was compiled and linked.
  62.  
  63.     - All the other PostScript Level 2 operators and facilities listed
  64. in section A.1.1 of the Second Edition and not listed in any of the other
  65. A.1.n sections.  These facilities are only available if the level2 feature
  66. was selected at the time that Ghostscript was compiled and linked.
  67.  
  68. Adding all of these produces a full Level 2 PostScript language
  69. interpreter.
  70.  
  71. Ghostscript also includes a number of operators defined below that are not
  72. in the PostScript language.
  73.  
  74. Implementation limits
  75. =====================
  76.  
  77. The following implementation limits correspond to those in Table B.1 and
  78. B.2 of the Second Edition.  Those marked with * are different from the ones
  79. in the Second Edition.
  80.  
  81. Architectural limits
  82. --------------------
  83.  
  84. integer        32-bit two's complement integer
  85. real        single-precision IEEE float
  86. *array
  87.     On 16-bit systems:    8191 elements
  88.     On 32-bit systems:    65535 elements
  89. *dictionary
  90.     On 16-bit systems:    8190 elements
  91.     On 32-bit systems:    65534 elements
  92. *string        65535 characters
  93. *name        16383 characters
  94. filename    100 characters
  95. *save level    none (capacity of memory)
  96. *gsave level    none (capacity of memory)
  97.  
  98. Typical memory limits in Level 1
  99. --------------------------------
  100.  
  101. userdict        200
  102. FontDirectory        100
  103. *operand stack        800
  104. dictionary stack    20
  105. execution stack        250
  106. *interpreter level    none (capacity of memory)
  107. *path            none (capacity of memory)
  108. dash            11
  109. *VM            capacity of memory
  110. *file            determined by operating system
  111. *image            65535 values (samples x components) for 1, 2, 4,
  112.               or 8-bit samples; 32767 values for 12-bit samples
  113.  
  114. Other differences in VM consumption
  115. -----------------------------------
  116.  
  117. Packed array elements occupy either 2 bytes or 8 bytes.  The average
  118. element size is probably about 5 bytes.
  119.  
  120. Names occupy 12 bytes plus the space for the string.
  121.  
  122. Ghostscript-specific additions
  123. ==============================
  124.  
  125. Miscellaneous
  126. -------------
  127.  
  128. ^D and ^Z are self-delimiting tokens, like [ and ].  They are initially
  129. defined as empty procedures so that they will be ignored in the input
  130. stream.
  131.  
  132. run can take either a string or a file as its argument.  In the latter
  133. case, it just runs the file, closing it at the end, and trapping errors
  134. just as for the string case.
  135.  
  136. Mathematical operators
  137. ----------------------
  138.  
  139.     <number> arccos <number>
  140.         Computes the arc cosine of a number between -1 and 1.
  141.  
  142.     <number> arcsin <number>
  143.         Computes the arc sine of a number between -1 and 1.
  144.  
  145. String operators
  146. ----------------
  147.  
  148.     <state> <fromString> <toString> .type1encrypt <newState> <toSubstring>
  149.         Encrypts fromString according to the algorithm for Adobe
  150.           Type 1 fonts, writing the result into toString.
  151.           toString must be at least as long as fromString or a
  152.           rangecheck error occurs.  state is the initial state of
  153.           the encryption algorithm (a 16-bit non-negative
  154.           integer); newState is the new state of the algorithm.
  155.  
  156.     <state> <fromString> <toString> .type1decrypt <newState> <toSubstring>
  157.         Decrypts fromString according to the algorithm for Adobe
  158.           Type 1 fonts, writing the result into toString.  Other
  159.           specifications are as for type1encrypt.
  160.  
  161. Relational operators
  162. --------------------
  163.  
  164.     <number|string> <number|string> max <number|string>
  165.         Returns the larger of two numbers or strings.
  166.  
  167.     <number|string> <number|string> min <number|string>
  168.         Returns the smaller of two numbers or strings.
  169.  
  170. File operators
  171. --------------
  172.  
  173.     <string> findlibfile <foundstring> <file> true
  174.     <string> findlibfile <string> false
  175.         Opens the file of the given name for reading, searching
  176.           through directories as described in use.doc.  If the
  177.           search fails, findlibfile simply pushes false on the
  178.           stack and returns, rather than causing an error.
  179.  
  180.     <file> <integer> unread -
  181.          Pushes back the last-read character onto the front of the
  182.           file.  If the file is only open for writing, or if the
  183.           integer argument is not the same as the last character
  184.           read from the file, causes an ioerror error.  May also
  185.           cause an ioerror if the last operation on the file was not
  186.           a reading operation.
  187.  
  188.     <file> <device> writeppmfile -
  189.         Writes the contents of the device, which must be an image
  190.           device, onto the file, in Portable PixMap (ppm) format.
  191.           Does not close the file.
  192.  
  193. Path operators
  194. --------------
  195.  
  196.     <x> <y> <width> <height> rectappend -
  197.     <numarray> rectappend -
  198.     <numstring> rectappend -
  199.         Appends a rectangle or rectangles to the current path, in
  200.           the same manner as rectfill, rectclip, etc.  Only
  201.           defined if the dps option is selected.
  202.  
  203. Filters
  204. -------
  205.  
  206. Ghostscript supports all the standard PostScript Level 2 filters.  In
  207. addition, Ghostscript supports the following non-standard filters:
  208.  
  209.     <target> <seed_integer> /eexecEncode filter <file>
  210.         Creates a filter for encrypting data into the
  211.           eexec encrypted format described in the
  212.           Adobe Type 1 Font Format documentation.  The
  213.           seed_integer must be 55665 for proper operation.
  214.           This filter produces binary output and does not
  215.           include the initial 4 garbage bytes.
  216.  
  217.     <source> <seed_integer> /eexecDecode filter <file>
  218.         Creates a filter for decrypting data that has been
  219.           encrypted using eexec encryption as described in the
  220.           Adobe Type 1 Font Format documentation.  The
  221.           seed_integer must be 55665 for proper operation.
  222.  
  223.     <source> <hex_boolean> /PFBDecode filter <file>
  224.         Creates a filter that decodes data in .PFB format, the
  225.           usual semi-binary representation for Type 1 font files
  226.           on IBM PC and compatible systems.  If hex_boolean is true,
  227.           binary packets are converted to hex; if false, binary
  228.           packets are not converted.
  229.  
  230. Various versions of Ghostscript may also support other non-standard filters
  231. for experimental purposes.  The current version includes the following
  232. non-standard filters, which are not documented further.  No guarantee is
  233. made that these filters will exist in compatible form, or at all, in future
  234. versions.
  235.  
  236.     <target/source> <string> ByteTranslateEncode/Decode
  237.     <target> <int> BigStringEncode
  238.     <target/source> BCPEncode/Decode
  239.     <target/source> TBCPEncode/Decode
  240.     <target/source> <dict> BoundedHuffmanEncode/Decode
  241.         FirstBitLowOrder <bool> false
  242.         MaxCodeLength <int> 16
  243.         EndOfData <bool> true
  244.         EncodeZeroRuns <int> 256
  245.         Tables <int_array>
  246.     <target/source> <dict> BWBlockSortEncode/Decode
  247.         BlockSize <int> 16384
  248.     <target/source> MoveToFrontEncode/Decode
  249.  
  250. Ghostscript also supports a non-standard optional dictionary operand for
  251. the LZWDecode filter, with the following keys (all optional):
  252.  
  253.     InitialCodeLength <integer>
  254.         An integer between 2 and 11 specifying the initial number
  255. of data bits per code.  Note that the actual initial code length is 1
  256. greater than this, to allow for the reset and end-of-data code values.
  257. Default value: 8.
  258.  
  259.     FirstBitLowOrder <boolean>
  260.         If true, codes appear with their low-order bit first.
  261. Default value: false.
  262.  
  263.     BlockData <boolean>
  264.         If true, the data is broken into blocks in the manner
  265. specified for the GIF file format.  Default value: false.
  266.  
  267.     EarlyChange <integer>
  268.         If 0, codes become one bit longer one code earlier than
  269. they need to; if 1, codes become one bit longer as specified in the
  270. PostScript Language Reference Manual.  Default value: 1.
  271.  
  272. Virtual memory operators
  273. ------------------------
  274.  
  275.     <save> .forgetsave -
  276.         Cancels the effect of a save -- makes it as though the
  277.           save never happened.
  278.  
  279. Miscellaneous operators
  280. -----------------------
  281.  
  282.     - currenttime <number>
  283.         Returns the current value of a continuously-running timer,
  284.           in minutes.  The initial value of this timer is undefined.
  285.  
  286.     <string> getenv <string> true
  287.     <string> getenv false
  288.         Looks up a name in the shell environment.  If the name is
  289.           found, returns the corresponding value and true; if the
  290.           name is not found, returns false.
  291.  
  292.     <name> <array> makeoperator <operator>
  293.         Constructs and returns a new operator that is actually the
  294.           given procedure in disguise.  The name is only used for
  295.           printing.  The operator has the executable attribute.
  296.  
  297.     <string> <boolean> .setdebug -
  298.         If the Ghostscript interpreter was built with the DEBUG
  299.           flag set, sets or resets any subset of the debugging
  300.           flags normally controlled by -Z in the command line.
  301.           Has no effect otherwise.
  302.  
  303.     - .oserrno <errno>
  304.         Returns the error code for the most recent OS error.
  305.  
  306.     - .oserror <string>
  307.         Returns the error string for the most recent OS error.
  308.  
  309. Device operators
  310. ----------------
  311.  
  312.     <device> copydevice <device>
  313.         Copies a device.
  314.  
  315.     <index> .getdevice <device>
  316.         Returns a device from the set of devices known to the
  317.           system.  The first device, which is default, is numbered
  318.           0.  If the index is out of range, causes a rangecheck
  319.           error.
  320.  
  321.     <matrix> <width> <height> <palette> makeimagedevice <device>
  322.         Makes a new device that accumulates an image in memory.
  323.           matrix is the initial transformation matrix: it must be
  324.           orthogonal (i.e., [a 0 0 b x y] or [0 a b 0 x y]).
  325.           palette is a string of 2^N or 3*2^N elements, specifying
  326.           how the 2^N possible pixel values will be interpreted.
  327.           Each element is interpreted as a gray value, or as RGB
  328.           values, multiplied by 255.  For example, if you want
  329.           a monochrome image for which 0=white and 1=black, the
  330.           palette should be <ff 00>; if you want a 3-bit deep
  331.           image with just the primary colors and their complements
  332.           (ignoring the fact that 3-bit images are not supported),
  333.           the palette might be <000000 0000ff 00ff00 00ffff
  334.           ff0000 ff00ff ffff00 ffffff>.  At present, the palette
  335.           must contain exactly 2, 4, 16, or 256 entries,
  336.           and must contain an entry for black and an entry
  337.           for white; if it contains any entries that aren't black,
  338.           white, or gray, it must contain at least the six primary
  339.           colors (red, green, blue, and their complements cyan,
  340.           magenta, and yellow); aside from this, its contents are
  341.           arbitrary.
  342.         Alternatively, palette can be null.  This is interpreted
  343.           as 24-bit-per-pixel color, where the four bytes of each
  344.           pixel are respectively R, G, and B.
  345.         Note that one can also make an image device (with the same
  346.           palette as an existing image device) by copying a device
  347.           using the copydevice operator.
  348.  
  349.     <device> <index> <string> copyscanlines <substring>
  350.         Copies one or more scan lines from an image device into a
  351.           string, starting at a given scan line in the image.
  352.           The data is in the same format as for the image
  353.           operator.  Error if the device is not an image device or
  354.           if the string is too small to hold at least one complete
  355.           scan line.  Always copies an integral number of scan
  356.           lines.
  357.  
  358.     <device> setdevice -
  359.         Sets the current device to the specified device.  Also
  360.           resets the transformation and clipping path to the
  361.           initial values for the device.
  362.  
  363.     - currentdevice <device>
  364.         Gets the current device from the graphics state.
  365.  
  366.     <device> getdeviceprops <mark> <name1> <value1> ... <namen> <valuen>
  367.         Gets all the properties of a device.  Currently defined
  368.           names and values for all devices are:
  369.             BitsPerPixel <integer>
  370.                 Usually read-only.  Number of bits per pixel.
  371.             .HWMargins [<4 floats>]
  372.                 Size of non-imageable regions around edges
  373.                   of page, in 1/72" units.
  374.             HWSize [<integer> <integer>]
  375.                 X and Y size in pixels.
  376.             Name <string>
  377.                 Read-only.  The device name.
  378.                   Currently, same as OutputDevice.
  379.             Colors, GrayValues, RedValues, GreenValues,
  380.               BlueValues, ColorValues
  381.                 As for the 'deviceinfo' operator of
  382.                   Display PostScript.
  383.         In addition, the following are defined per Adobe's
  384.           documentation for the setpagedevice operator:
  385.             Duplex (if supported)
  386.             HWResolution
  387.             ImagingBBox
  388.             Margins
  389.             NumCopies (for printers only)
  390.             Orientation (if supported)
  391.             OutputDevice
  392.             PageSize
  393.             ProcessColorModel
  394.         Some devices may only allow certain values for
  395.           HWResolution and PageSize.  The null device ignores
  396.           attempts to set PageSize; its size is always [0 0].
  397.         Red/Green/Blue/ColorValues are only defined if Colors > 1.
  398.         For printers, the following are also defined:
  399.             BufferSpace <integer>
  400.                 Buffer space for band lists, if the bitmap
  401.                   is too big to fit in RAM.
  402.             MaxBitmap <integer>
  403.                 Maximum space for a full bitmap in RAM.
  404.             OutputFile <string>
  405.                 () means send to printer directly,
  406.                   otherwise specifies the file name for
  407.                   output; a %d is replaced by the page #;
  408.                   on Unix systems, (|command) writes to a pipe
  409.             OpenOutputFile <boolean>
  410.                 If true, open the device's output file
  411.                   when the device is opened, rather than
  412.                   waiting until the first page is ready to
  413.                   print.
  414.             .PageCount <integer>
  415.                 Read-only.  Counts the number of pages
  416.                   printed on the device.
  417.  
  418.     <mark> <name1> <value1> ... <namen> <valuen> <device>
  419.         putdeviceprops <device>
  420.         Sets properties of a device.  May cause undefined,
  421.           typecheck, rangecheck, or limitcheck errors.
  422.  
  423.     - flushpage -
  424.         On displays, flushes any buffered output, so that it
  425.           is guaranteed to show up on the screen; on printers,
  426.           has no effect.
  427.  
  428. Character operators
  429. -------------------
  430.  
  431.     <string> .type1addpath -
  432.     <string> <lsbx> <lsby> .type1addpath -
  433.         Adds the description of a character to the current
  434.           path.  The string argument is a scalable
  435.           description encoded in Adobe Type 1 format.  This
  436.           operator, like setcharwidth and setcachedevice, is
  437.           only valid in the context of a show operator.  It
  438.           uses information from the current font, in addition
  439.           to the argument(s).
  440.         The optional lsbx and lsby arguments are left side
  441.           bearing values that override the ones in the
  442.           character outline.
  443.  
  444.     <font> <char> Type1BuildChar -
  445.         This is not a new operator: rather, it is a name known
  446.           specially to the interpreter.  Whenever the interpreter
  447.           needs to render a character (during a ...show,
  448.           stringwidth, or charpath), it looks up the name
  449.           BuildChar in the font dictionary to find a procedure to
  450.           run.  If it does not find this name, and if the FontType
  451.           is 1, the interpreter instead uses the value (looked up
  452.           on the dictionary stack in the usual way) of the name
  453.           Type1BuildChar.
  454.         The standard definition of Type1BuildChar is in gs_fonts.ps.
  455.           Users should not need to redefine Type1BuildChar, except
  456.           perhaps for tracing or debugging.
  457.  
  458. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  459.  
  460. PostScript is a trademark of Adobe Systems, Incorporated.
  461.